package com.igoal.comparator;

import java.util.Comparator;

import com.igoal.entity.Goal;

/**
 * Sort by number of user using goal
 * @author Tri
 *
 */
public class GoalComparator extends BaseComparator implements Comparator<Goal>{	
	public GoalComparator(boolean isASC) {
		this.isASC = isASC;
	}
	
	public int compare(Goal o1, Goal o2) {
		if(o1 == null || o2 == null) return 0;
		if(isASC)
			return o1.getUserCount().compareTo(o2.getUserCount());
		else
			return o2.getUserCount().compareTo(o1.getUserCount());
	}

}
